package com.svs.quartz.domain;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.svs.common.annotation.Excel;
import com.svs.common.base.BaseEntity;
import com.svs.common.utils.data.entity.DBLink;
import com.svs.quartz.helper.Dialect;
import com.svs.quartz.helper.WisDataSourceHelper;

/**
 * 数据源表 wis_data_source
 * 
 * @author 杜建桥
 * @date 2019-02-15
 */
public class WisDataSource extends BaseEntity<WisDataSource> {

	private static final long serialVersionUID = 1L;

	/** 主键 */
	private Long id;

	/** 名称 */
	@Excel(name = "名称")
	private String name;

	/** 类型 */
	@Excel(name = "类型")
	private String dialect;

	/** 主机 */
	@Excel(name = "主机")
	private String host;

	/** 登陆名 */
	@Excel(name = "登陆名")
	private String username;

	/** 密码 */
	@Excel(name = "密码")
	private String password;

	/** 端口号 */
	@Excel(name = "端口号")
	private String port;

	/** 数据库名字 */
	@Excel(name = "数据库")
	private String dbName;

	/** 状态 */
	private Integer state;
	
	public DBLink getDBLink() {
		DBLink dbLink = new DBLink(id+name, host, port, username, password, dbName) ;
		dbLink.setSourceType(WisDataSourceHelper.getDbType(dialect));
		return dbLink ;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public Dialect getDialectEnum() {
		return WisDataSourceHelper.getDialect(dialect);
	}
	
	public void setDialect(String dialect) {
		this.dialect = dialect;
	}

	public String getDialect() {
		return dialect;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public String getHost() {
		return host;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getUsername() {
		return username;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPassword() {
		return password;
	}

	public void setPort(String port) {
		this.port = port;
	}

	public String getPort() {
		return port;
	}

	public String getDbName() {
		return dbName;
	}

	public void setDbName(String dbName) {
		this.dbName = dbName;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	public Integer getState() {
		return state;
	}

	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("name", getName())
				.append("dialect", getDialect()).append("host", getHost()).append("username", getUsername())
				.append("password", getPassword()).append("port", getPort()).append("createBy", getCreateBy())
				.append("createTime", getCreateTime()).append("updateBy", getUpdateBy())
				.append("updateTime", getUpdateTime()).append("state", getState()).toString();
	}
}
